#!/bin/sh

# If a specific java binary isn't specified search for the standard 'java' binary
if [ -z "$JAVACMD" ] ; then
  if [ -n "$JAVA_HOME"  ] ; then
    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
      JAVACMD="$JAVA_HOME/jre/sh/java"
    else
      JAVACMD="$JAVA_HOME/bin/java"
    fi
  else
    JAVACMD=`which java`
  fi
fi

if [ ! -x "$JAVACMD" ] ; then
  echo "Error: JAVA_HOME is not defined correctly." 1>&2
  echo "  We cannot execute $JAVACMD" 1>&2
  exit 1
fi

CLASSPATH=@CLASSPATH@
JVMPARAMS=@JVMPARAMS@
CONFIG=@CONFIG@
MAINCLASS=@MAINCLASS@

exec "$JAVACMD" "$JVMPARAMS" -classpath "$CLASSPATH" -Dconfig="CONFIG" "$MAINCLASS"
